package com.swn.cm.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.swn.common.util.DbHelper;

@Service
public class LoginService {
	@Autowired
	DbHelper dbHelper;
	
	public List<Map<String, Object>> queryEmp(String name){
		StringBuilder sql = new StringBuilder();
		Map<String,Object> queryMap=new HashMap<>();
		sql.append(" select id,emp_ability,emp_name,login_user,login_pwd  ")
		.append(" ,ifnull((")
		.append("    select group_concat(role_id)role_id  from shop_cm_employee_role where employee_id=a.id")
		.append("  ),'')role_id")
		.append(" ,ifnull((")
		.append("      select group_concat(id) features from shop_cm_menu_features")
		.append("    ),'')features")   //所有的具体功能
		.append(" from")
		.append(" (")
		.append("  select id,emp_ability,emp_name,login_user,login_pwd from shop_cm_employee where login_user=:login_user")
		.append(" )a ");
		queryMap.put("login_user", name);
		return dbHelper.queryForList(sql.toString(),queryMap);
	}
}
